import JSONBigint from 'json-bigint';
export default {
  get(key) {
    if (!key) console.Error('storage key is empty');

    let result = localStorage.getItem(key);

    try {
      result = JSONBigint.parse(result);
    } catch (e) {}

    return result;
  },

  set(key, value) {
    if (!key) console.error('storage key is empty');
    typeof value === 'object' && (value = JSONBigint.stringify(value));
    localStorage.setItem(key, value);
  },

  remove(key) {
    localStorage.removeItem(key);
  },

  clean() {
    localStorage.clear();
  }
};
